package com.livestocksolutions.util;

import android.os.Parcel;
import android.os.Parcelable;

/* -- Version History --
 *  1.0 : 10 September 2012 - Initial version.
 */

/**
 * Allows saving a Single dimensional String array into a Parcelable Object.
 * @author Adam Parr
 * @version 1.0
 * 
 * @.modified 10 September 2012
 */
public class StringParcelable implements Parcelable {
	/**
	 * The String Array in which to place into a Parcelable.
	 */
	public String[] strings;

    /**
     * Constructor
     */
    public StringParcelable() {
        strings = new String[1];
    }
	
	/**
	 * Get the Array of Strings.
	 * @return The Array of Strings given to this Parcelable.
	 */
    public String[] getStrings() {
        return strings;
    }

    /**
     * Set an Array of Strings to retreive at a later time.
     * @param strings The Array of Strings to give to this Parcelable.
     */
    public void setStrings(String[] strings) {
        this.strings = strings;
    }

    /**
     * Store the array of Strings in the given Parcel.
     * @param in Parcel to store the Array of Strings.
     */
    public StringParcelable(Parcel in) {
         in.readStringArray(strings);
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(strings);
    }
    public static final Parcelable.Creator<StringParcelable> CREATOR = new Parcelable.Creator<StringParcelable>() {
        public StringParcelable createFromParcel(Parcel in) {
            return new StringParcelable(in);
        }

        public StringParcelable[] newArray(int size) {
            return new StringParcelable[size];
        }
    };
}
